﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using eTMS.Controllers;
using eTMS.Forms.Reports;

namespace eTMS.Forms.Reviews
{
    public partial class FrmDanhSachDeNghiLuuBan : eTMS.Controls.BaseForm
    {
        public FrmDanhSachDeNghiLuuBan()
        {
            InitializeComponent();
        }
        SinhVienController controller;
        private void FrmDanhSachDeNghiLuuBan_Load(object sender, EventArgs e)
        {
            controller = new SinhVienController();
            LoaiDiemController.LoadAllLoaiDiem(false);
            HocKyController.LoadAllHocKy(false);
            NamHocController.LoadAllNamHoc(false);
            comboBoxNamHoc1.BindData();
            comboBoxHocKy1.BindData();
            treeKhoaNganhKhoaHoc1.InitData();
        }

        private void btnLoadData_Click(object sender, EventArgs e)
        {
            if (comboBoxHocKy1.SelectedIndex < 0)
            {
                ShowWarning("Bạn phải chọn một học kỳ!");
                return;
            }
            if (comboBoxNamHoc1.SelectedIndex < 0)
            {
                ShowWarning("Bạn phải chọn một năm học!");
                return;
            }
            controller.LoadDanhSachHocLai((int)comboBoxHocKy1.SelectedValue,(int)comboBoxNamHoc1.SelectedValue,treeKhoaNganhKhoaHoc1.SelectedKhoa_ID, treeKhoaNganhKhoaHoc1.SelectedNganhHoc_ID, treeKhoaNganhKhoaHoc1.SelectedLop_ID, treeKhoaNganhKhoaHoc1.KhoaHoc_ID);
            gridData.AutoGenerateColumns = false;
            gridData.DataSource = controller.Table;
        }

        private void btnCreateDS_Click(object sender, EventArgs e)
        {
            controller.LapDanhSachHocLai((int)treeKhoaNganhKhoaHoc1.KhoaHoc_ID, (int)comboBoxHocKy1.SelectedValue, (int)comboBoxNamHoc1.SelectedValue);
            btnLoadData_Click(sender, e);
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            Reports.FrmHtmlReportView frmHtmlReportView = new FrmHtmlReportView();
            frmHtmlReportView.SetDataSource(controller.Table, "14_DanhSachLuuBan.htm");            
            frmHtmlReportView.ShowDialog();
        }
    }
}
